package canss.webservice.controls;

import org.apache.beehive.controls.api.bean.Control;
import org.apache.beehive.controls.api.bean.ControlImplementation;

import canss.webservice.model.ModuleDesc;

import weblogic.jdbc.SQLExceptionWrapper;

import java.io.Serializable;

@ControlImplementation
public class ModuleDescControlImpl implements ModuleDescControl, Serializable
{
	private static final long serialVersionUID = 8031619723601370807L;

	@Control
	private BusinessSystemDB businesssystemDB;
	
	
	public Boolean checkModuleDesc(String _mid) throws SQLExceptionWrapper
	{
		int ret = businesssystemDB.checkModuleDesc(_mid);
		return ret>0;
	}
	
	public Boolean removeModuleDesc(String _mid) throws SQLExceptionWrapper
	{
		int ret = businesssystemDB.removeModuleDesc(_mid);
		return ret>0;
	}
	
	public Boolean addModuleDesc(String _mid, String _pid, String _name, String _commands, String _netaddr) throws SQLExceptionWrapper
	{
		int ret = businesssystemDB.addModuleDesc(_mid, _pid, _name, _commands, _netaddr, System.currentTimeMillis());
		return ret>0;
	}
	
	public ModuleDesc[] getEntireModuleDesc() throws SQLExceptionWrapper
	{
		ModuleDesc[] ret = businesssystemDB.getEntireModuleDesc();
		return ret;
	}


	public Boolean updateModuleDescStatus(String _mid, String _midstatus) throws SQLExceptionWrapper
	{
		int ret = businesssystemDB.updateModuleDescStatus(_mid, _midstatus, System.currentTimeMillis());
		return ret>0;
	}
}